-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement locks for RedisCluster #2013
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2013 +/- ##
==========================================
- Coverage 92.62% 92.62% -0.01%
==========================================
Files 100 100
Lines 20910 20913 +3
==========================================
+ Hits 19368 19370 +2
- Misses 1542 1543 +1
Continue to review full report at Codecov.
|
@@ -224,7 +224,7 @@ def owned(self): | |||
# need to always compare bytes to bytes | |||
# TODO: this can be simplified when the context manager is finished | |||
if stored_token and not isinstance(stored_token, bytes): | |||
encoder = self.redis.connection_pool.get_encoder() | |||
encoder = self.redis.get_encoder() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm beginning to confuse myself a bit -- I think this is a safe change since both redis classes have the .get_encoder()
method defined on them already? But I'm not positive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're right. Since merging in cluster and asyncio, we actually need to start cleaning and unifying these interfaces. There's a lot of duplication - but the philosophy was first get it in, then clean it up.
@dvora-h concur?
.lock()
for RedisCluster.lock()
method on RedisCluster
@@ -94,10 +96,10 @@ | |||
* Removing command on initial connections (#1722) | |||
* Removing hiredis warning when not installed (#1721) | |||
* 4.0.0 (Nov 15, 2021) | |||
* FT.EXPLAINCLI intentionally raising NotImplementedError | |||
* FT.EXPLAINCLI intentionally raising NotImplementedError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry for these whitespace trims -- my IDE does it 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flake8 actually enforces it, but only on python files ;)
.lock()
method on RedisCluster
I think the tests are flaky 🤔 -- they pass fine on my machine, at least |
… into redis-cluster-lock
Awesome @jakebarnwell, thank you for the PR! I merge it into master. |
What about asyncio cluster client? |
Pull Request check-list
Please make sure to review and check all of these items:
$ tox
pass with this change (including linting)?NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open.
Description of change
Adds support for the
lock()
method onRedisCluster
. Currently, onlyRedis
class supportslock()
. #1937 added lua scripting support forRedisCluster
which is a prerequisite for locking support, so with that out of the way, this PR finishes adding support for the.lock()
method.The change is relatively simple: we just copy and paste the
Redis.lock()
implementation ontoRedisCluster.lock()
. However, we do change theLock
implementation for acquiring the encoder if necessary. Instead of callingself.redis.connection_pool.get_encoder()
, we now callself.redis.get_encoder()
. Both of these methods already exist so it shouldn't be breaking (?).